package com.purong.purong.activity;

import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.purong.purong.PuRongApp;
import com.purong.purong.R;
import com.purong.purong.bean.BankLoanDetBean;
import com.purong.purong.widget.RadiusImageView;
import com.yao.sdk.glide.GlideUtil;

/**
 * Created by zengwenjie on 2017/12/6.
 */
public class BankLoanResultActivity extends BaseActivity {
    private RadiusImageView img;
    private TextView nameTv,moneyTv,periodTv;
    private BankLoanDetBean detBean;
    private String applyMoney,applyPeriod,loanApplyId;
    private LinearLayout identifyLay;

    @Override
    public int getRootViewId() {
        return R.layout.activity_loan_apply_result;
    }

    @Override
    public void initBundle() {
        detBean=(BankLoanDetBean)getIntent().getSerializableExtra("BANK_LOAN");
        applyMoney=getIntent().getStringExtra("APPLY_MONEY");
        applyPeriod=getIntent().getStringExtra("APPLY_PERIOD");
        loanApplyId=getIntent().getStringExtra("APPLY_ID");
    }

    @Override
    public void initView() {
        img=(RadiusImageView)findViewById(R.id.img);
        nameTv=(TextView)findViewById(R.id.name);
        moneyTv=(TextView)findViewById(R.id.money);
        periodTv=(TextView)findViewById(R.id.period);
        identifyLay=(LinearLayout)findViewById(R.id.identify_lay);
        if (PuRongApp.getLoginInfo(this)!=null){
            if (PuRongApp.getLoginInfo(this).getIs_real().equals("1")){
                identifyLay.setVisibility(View.VISIBLE);
            }
        }
    }

    @Override
    public void initData() {

        GlideUtil.getInstance().load(this,detBean.getLoan_product_url(),img,true);
        nameTv.setText(detBean.getLoan_product_name());
        moneyTv.setText(applyMoney);
        periodTv.setText(applyPeriod);
    }
    public void onClick(View v){
        switch (v.getId()){
            case R.id.identify:
                Intent intent=new Intent(this,RealIdentifyActivity.class);
                startActivity(intent);
                finish();
                break;
            case R.id.detial:
                Intent detIntent=new Intent(this,LoanRecordDetActivity.class);
                detIntent.putExtra("APPLY_ID",loanApplyId);
                detIntent.putExtra("TYPE", LoanRecordDetActivity.BANK_LOAN);
                startActivity(detIntent);
                finish();
                break;
            case R.id.left_back:
                finish();
                break;
            case R.id.confirm:
                finish();
                break;
        }
    }
}
